package com.artPreter.pojo.vos.page;

import com.baomidou.mybatisplus.annotation.TableField;
import com.artPreter.pojo.AlertDevice;
import com.artPreter.pojo.AlertMessage;
import com.artPreter.pojo.InputDevice;
import lombok.Data;

@Data
public class DeviceMesage {
    // 设备uuid
    public String uuid;

    // 设备类型 1:温湿度 3:漏水 4:烟感")
    public Integer type;
    // 设备名称
    public String deviceName;

    //设备地图横坐标
    private Double locX;

    //设备地图纵坐标
    private Double locY;

    //区域uuid
    @TableField("position")
    private String position;

    //楼层uuid
    private String floor;

    //房间uuid
    private String room;

    private String roomName;

    private String floorName;

    private String positionName;

    private String message;

    //报警状态
    private Integer status = 0;

    public DeviceMesage() {
    }

    public DeviceMesage(String uuid, Integer type, String deviceName, Double locX, Double locY, String position, String floor, String room) {
        this.uuid = uuid;
        this.type = type;
        this.deviceName = deviceName;
        this.locX = locX;
        this.locY = locY;
        this.position = position;
        this.floor = floor;
        this.room = room;
    }

    public DeviceMesage(InputDevice inputDevice) {
        this.room = inputDevice.getRoom();
        this.floor = inputDevice.getFloor();
        this.position = inputDevice.getPosition();
        this.locX = inputDevice.getLocX();
        this.locY = inputDevice.getLocY();
        this.deviceName = inputDevice.getDeviceName()+"设备";
        this.type = 1;
        this.uuid = inputDevice.getUuid();
    }

    public DeviceMesage(AlertDevice alertDevice) {
        this.room = alertDevice.getRoom();
        this.floor = alertDevice.getFloor();
        this.position = alertDevice.getPosition();
        this.locX = alertDevice.getLocX();
        this.locY = alertDevice.getLocY();
        this.deviceName = alertDevice.getDeviceName()+"设备";
        switch (alertDevice.getType()){
            case 1:
                this.type = 4;
                break;
            case 2:
                this.type = 3;
                break;
        }
        this.uuid = alertDevice.getUuid();
    }

    public DeviceMesage(AlertMessage alertMessage) {
        this.room = alertMessage.getRoom();
        this.floor = alertMessage.getFloor();
        this.position = alertMessage.getPosition();
        this.positionName = alertMessage.getPosiName();
        this.floorName = alertMessage.getFloorName();
        this.roomName = alertMessage.getRoomName();
        if(alertMessage.getType()==1){
            this.type = 1;
            this.deviceName = "温度设备";
            this.message = "温度过高";
        }else if(alertMessage.getType()==2){
            this.type = 2;
            this.deviceName = "湿度设备";
            this.message = "湿度过高";
        }else if(alertMessage.getType()==3){
            this.type = 3;
            this.deviceName = "漏水设备";
            this.message = "出现漏水";
        }else if(alertMessage.getType()==4){
            this.type = 4;
            this.deviceName = "烟感设备";
            this.message = "感应烟雾";
        }

    }
}
